'use strict'

/** @type {import('sequelize-cli').Migration} */
module.exports = {
  async up(queryInterface, Sequelize) {
    const { INTEGER, STRING, DATE } = Sequelize
    // 创建表
    await queryInterface.createTable('user', {
      id: {
        type: INTEGER(20).UNSIGNED,
        primaryKey: true,
        autoIncrement: true
      },
      username: {
        type: STRING(30),
        comment: '用户名称'
      },
      nickname: {
        type: STRING(30),
        comment: '昵称'
      },
      email: {
        type: STRING(160),
        comment: '用户邮箱'
      },
      password: {
        type: STRING,
        comment: '密码'
      },
      avatar: {
        type: STRING(500),
        comment: '头像'
      },
      status: {
        type: INTEGER(1),
        defaultValue: 1,
        comment: '状态-1:正常,2:禁用'
      },
      type: {
        type: INTEGER(1),
        defaultValue: 1,
        comment: '类型-1:用户,2:游客'
      },
      ip: {
        type: STRING(100),
        comment: 'ip地址'
      },
      created_time: DATE
    })
  },

  async down(queryInterface, Sequelize) {
    await queryInterface.dropTable('user')
  }
}
